define([
    'app'
], function (app) {
    app.controller('sidebarCtrl', sidebarCtrl); //菜单状态切换
    sidebarCtrl.$inject = ['$scope', '$rootScope'];

    function sidebarCtrl($scope, $rootScope) {
        // 注意$scope.$watch()只能监视$scope上的视图模型成员，也可以监视方法的返回值 
        $rootScope.$on('$stateChangeSucess', function (event, toState, toParams, fromState, fromParams) {
           console.log('foo')
            console.log(toState.name);
            console.log(toParams);
        })

    }
    app.directive('sideBar', function ($rootScope) {
        return {
            restrict: 'A',
            link: function (scope, ele, attr) {
                angular.element(ele).find('li').on('click', function () {
                    $(this).addClass('active').siblings().removeClass('active');
                })

            }
        }
    })
})